package com.arpa.oms.service;

import com.arpa.oms.domain.dto.OmsAllocationDTO;
import com.arpa.oms.domain.entity.OmsAllocation;
import com.arpa.oms.domain.vo.OmsAllocationVO;
import com.arpa.wms.domain.entity.Outbound;
import com.arpa.wms.domain.entity.Putaway;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * OMS调拨单 服务类
 * </p>
 *
 * @author LEO
 * @since 2020-11-17
 */
public interface IOmsAllocationService extends IService<OmsAllocation> {

    /**
     * 保存
     * @param entity
     * @return
     */
    @Override
    boolean save(OmsAllocation entity);

    /**
     * 根据code更新实体
     * @param entity
     * @return
     */
    int updateByCode(OmsAllocation entity);

    /**
     * 查询列表
     * @param omsAllocationDTO
     * @return
     */
    List<OmsAllocationVO> queryList(OmsAllocationDTO omsAllocationDTO);

    /**
     * 查询合计,包含总数
     * @param omsAllocationDTO
     * @return
     */
    OmsAllocationVO queryListSum(OmsAllocationDTO omsAllocationDTO);

    /**
     * 根据code获取调拨单
     * @param code
     * @return
     */
    OmsAllocationVO getOneByCode(String code);

    /**
     * 审核 调拨单
     * @param omsAllocation
     * @return
     */
    int audit(OmsAllocation omsAllocation);

    /**
     * 作废 调拨单
     * @param code
     * @return
     */
    int invalid(String code);

    /**
     * 根据发货单更新调拨单以及生成OMS出库单
     * @param deliveryCode
     */
    void updateAllocation(String deliveryCode, Outbound outbound, Map<String, BigDecimal[]> sourceItemOutQuantity);

    /**
     * 根据收货单更新调拨单以及生成OMS入库单
     * @param receiveCode
     */
    void updateAllocationAndCreateOmsInbound(String receiveCode, Putaway putaway);

    /**
     * wms发货流程完全完成进行的操作，生成下一个仓库的收货单或oms入库单
     * @param sourceCode
     */
    void afterWmsFinishAllOutbound(String sourceCode);

    /**
     * wms流程生成oms出库单
     * @param sourceCode
     * @param outbound
     * @param sourceItemOutQuantity
     */
    void wmsSaveOmsOutboundByAllocation(String sourceCode, Outbound outbound, Map<String, BigDecimal[]> sourceItemOutQuantity);
    void wmsSaveOmsOutboundByAllocationOutBound(String sourceCode, Outbound outbound);
}
